package com.lv.controller;

import com.lv.data.Result;
import com.lv.model.TbBrand;
import com.lv.service.BrandService;
import com.lv.vo.BrandVo;
import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("brand")
public class BrandController {
    @Autowired
    private BrandService bs;

    //查询
    @PostMapping
    public Result brandList(@RequestBody BrandVo vo){
        List<BrandVo> voList = bs.brandList(vo);
        return Result.OK().setData(voList);
    }
    //回显
    @PostMapping(value = "toupdate")
    public Result toupdate(@RequestParam Long id){
        BrandVo vo = bs.toupdate(id);
        return Result.OK().setData(vo);
    }
    //修改
    @PutMapping
    public Result update(@RequestBody BrandVo vo ){
        bs.update(vo);
        return Result.OK();
    }

    //增加
    @PostMapping(value = "add")
    public Result add(@RequestBody BrandVo vo){
        bs.add(vo);
        return Result.OK();
    }

    //删除
    @DeleteMapping
    public Result delete(@RequestParam Long id){
        bs.delete(id);
        return Result.OK();
    }
}
